.global _start					/* 声明一个全局的标号 */
_start:
	ldr r0,=0x70000000		@ 设置硬件相关地址
	orr r0,r0,#0x13
	mcr p15,0,r0,c15,c2,4	@ 256M(0x70000000~0x7FFFFFFF)

	/*关看门狗*/
	ldr r0,=0x7E004000
	mov r1,#0
	str r1,[r0]
	
	/*设置时钟*/
	ldr sp,=0x0C004000		@设置C语言运行环境
	bl clock_init

	bl sdram_init


	/*重定位*/
	adr r0, _start
	ldr r1, =_start
	ldr r2, =bss_start
	cmp r0,r1
	beq clean_bss
copy_loop:
	ldr r3, [r0], #4
	str r3, [r1], #4
	cmp r1,r2
	bne copy_loop

	/*清BSS段*/
clean_bss:
	ldr r0, =bss_start
	ldr r1, =bss_end
	mov r2, #0
	cmp r0,r1
	beq on_ddr	
clean_loop:
	str r2, [r0], #4
	cmp r0,r1
	bne clean_loop

on_ddr:
	//ldr sp,=0x50006000	/*设置栈*/

	ldr pc, =main
//	bl main					/* 跳转到C函数去执行 */

halt:
	b halt
